package com.chenfan.mcn.enums;

import com.chenfan.mcn.constant.McnConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.concurrent.TimeUnit;

/**
 * 操作锁枚举
 *
 * @author wulg
 * @date 2021-08-23
 **/
@AllArgsConstructor
public enum OperateLockEnum {

    /** 红人列表 */
    STAR_BASIC_DATA(McnConstant.LOCK_PRIFIX + "star_basic_data:id_", 2000, TimeUnit.MILLISECONDS),

    /** 收入合同 */
    INCOME_CONTRACT(McnConstant.LOCK_PRIFIX + "income_contract:id_", 2000, TimeUnit.MILLISECONDS),

    /** 收入合同补充协议 */
    INCOME_CONTRACT_AGREEMENT(McnConstant.LOCK_PRIFIX + "income_contract_agreement:id_", 2000, TimeUnit.MILLISECONDS),

    /** 执行单 */
    CONTRACT_EXCUTION_ORDER(McnConstant.LOCK_PRIFIX + "contract_excution_order:id_", 2000, TimeUnit.MILLISECONDS),

    /** 采购合同 */
    PURCHASE_CONTRACT(McnConstant.LOCK_PRIFIX + "purchase_contract:id_", 2000, TimeUnit.MILLISECONDS),

    /** 红人返点合同 */
    STAR_REBATE_CONTRACT(McnConstant.LOCK_PRIFIX + "star_rebate_contract:id_", 2000, TimeUnit.MILLISECONDS),

    /** 年框合同 */
    YEAR_FRAME_CONTRACT(McnConstant.LOCK_PRIFIX + "year_frame_contract:id_", 2000, TimeUnit.MILLISECONDS),

    /** 年框合同补充协议 */
    YEAR_FRAME_CONTRACT_AGREEMENT(McnConstant.LOCK_PRIFIX + "year_frame_contract_agreement:id_", 2000, TimeUnit.MILLISECONDS),

    /** 客户返点审批单 */
    ANNUAL_REBATE_APPROVAL(McnConstant.LOCK_PRIFIX + "annual_rebate_approval:id_", 2000, TimeUnit.MILLISECONDS),

    /** 折扣返点审批单 */
    DISCOUNT_APPROVAL(McnConstant.LOCK_PRIFIX + "discount_approval:id_", 2000, TimeUnit.MILLISECONDS),

    /** 红人刊例 */
    STAR_RATE_CARD(McnConstant.LOCK_PRIFIX + "star_rate_card:id_", 2000, TimeUnit.MILLISECONDS),

    /** 红人刊例平台 */
    STAR_RATE_CARD_PLATFORM(McnConstant.LOCK_PRIFIX + "star_rate_card_platform:id_", 2000, TimeUnit.MILLISECONDS),

    /** 红人刊例配置 */
    STAR_RATE_CARD_CONFIG(McnConstant.LOCK_PRIFIX + "star_rate_card_config:id_", 2000, TimeUnit.MILLISECONDS),

    /** 红人月度结算单 */
    STAR_MONTHLY_SETTLEMENT(McnConstant.LOCK_PRIFIX + "star_monthly_settlement:id_", 2000, TimeUnit.MILLISECONDS),

    /** 红人月度结算单-按红人 */
    STAR_MONTHLY_SETTLEMENT_STARID(McnConstant.LOCK_PRIFIX + "star_monthly_settlement_detail:star_id_", 2000, TimeUnit.MILLISECONDS),

    /** 意向单 */
    INTENTION_ORDER(McnConstant.LOCK_PRIFIX + "intention_order:id_", 2000, TimeUnit.MILLISECONDS),

    /** 直播合同商品 */
    LIVE_CONTRACT_COMMODITY(McnConstant.LOCK_PRIFIX + "live_contract_commodity:id_", 2000, TimeUnit.MILLISECONDS),


    /** 直播红人结算单 */
    LIVE_STAR_SETTLEMENT(McnConstant.LOCK_PRIFIX + "live_star_settlement:id_", 2000, TimeUnit.MILLISECONDS),

    /** 审批流 */
    APPROVAL_FLOW(McnConstant.LOCK_PRIFIX + "approval_flow:id_", 2000, TimeUnit.MILLISECONDS),

    /** 收入合同-重发费用 */
    INCOME_CONTRACT_REPUSH(McnConstant.LOCK_PRIFIX + "income_contract_repush:id_", 2000, TimeUnit.MILLISECONDS),

    /** 品牌信息 */
    BRAND_INFO(McnConstant.LOCK_PRIFIX + "brand_info:id_", 2000, TimeUnit.MILLISECONDS),
    ;

    private String key;

    private long waitTimeout;

    private TimeUnit waitUnit;

    public String generateKey(Long suffix) {
        return this.key + suffix.toString();
    }

    public String generateKey(String suffix) {
        return this.key + suffix;
    }

    public long getWaitTimeout() {
        return waitTimeout;
    }

    public TimeUnit getWaitUnit() {
        return waitUnit;
    }
}
